package com.diandi.activity.bean;

public enum BorrowTypes {

	XSB(3, "新手标"), HQB(1, "活期宝"), YXJH(2, "定期宝"), SB(0, "散标"), IPHONE_INVEST(4, "苹果专享标"), YACHT_INVEST(5, "游艇投资"), HOTEL_INVEST(
			6, "酒店投资"), MJ(8, "秒借"), YYFQ_INVEST(9, "有用分期"), CAR_CREDIT_INVEST(10, "车信宝"),ACT_PACKAGE(99,"集合包");
	/**
	 * value
	 */
	private final String text;
	/**
	 * key
	 */
	private final int value;

	BorrowTypes(int value, String text) {
		this.value = value;
		this.text = text;
	}

	public static BorrowTypes getTextByValue(int value) {
		for (BorrowTypes item : BorrowTypes.values()) {
			if (item.getValue() == value) {
				return item;
			}
		}
		throw new RuntimeException(value + "不是合法的类型！");
	}

	public static BorrowTypes getValueByText(String text) {
		for (BorrowTypes item : BorrowTypes.values()) {
			if (item.getText().equals(text)) {
				return item;
			}
		}
		throw new RuntimeException(text + "不是合法的类型！");
	}

	public String getText() {
		return text;
	}

	public int getValue() {
		return value;
	}

	/**
	 * @param borrowType
	 * @return
	 * @return boolean
	 * @author yaojunbing
	 * @since 2015年12月30日
	 */
	public static boolean isValidBorrowTyps(int borrowType) {
		for (BorrowTypes item : BorrowTypes.values()) {
			if (item.getValue() == borrowType) {
				return true;
			}
		}
		return false;
	}
}
